<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="perm" uri="/WEB-INF/tld/perm.tld"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<script>
	var ctx="${ctx}";
</script>

<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />

	<link href="${ctx}/static/css/bootstrap.min.css?v=${static_version}" rel="stylesheet" />
	<link href="${ctx}/static/css/font-awesome.min.css" rel="stylesheet" />
	<link href="${ctx}/static/css/animate.min.css?v=${static_version}" rel="stylesheet" />
	<link href="${ctx}/static/css/style.min.css?v=${static_version}" rel="stylesheet" />
	<link href="${ctx}/static/css/common.css?v=${static_version}" rel="stylesheet" />
	<link href="//at.alicdn.com/t/font_9x03jhokyws9vn29.css" rel="stylesheet">
	<!-- 插件样式  -->
	<link href="${ctx}/static/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
	<link href="${ctx}/static/css/plugins/webuploader/webuploader.css" rel="stylesheet" />
	<link href="${ctx}/static/css/plugins/markdown/bootstrap-markdown.min.css" rel="stylesheet" />

	<title>发布商品</title>
</head>

<body class="gray-bg">
	<div class="wrapper wrapper-content  animated fadeInRight">
			<div class="ibox float-e-margins">
								
        		<!-- 发布商品 -->
                <div class="ibox-title">
                    <h5>商品基本信息<small></small></h5>
                </div>
 		
		<form action="${ctx}/seller/goods-add" method="post" class="form form-horizontal" id="form-goods-add">
		
			<div class="ibox-content">			
				<input type="hidden" id="id" name="id" value='${goods.id}' />
				<input type="hidden" id="isZiYing" name="isZiYing" value="${isZiYing}">  
				
				<c:if test="${ !empty goods}">
					<div class="form-group">
						<div class="col-sm-10">
							<a class="btn btn-primary radius" onclick="updateStatus(1);" href="javascript:;">上架</a>
							<a class="btn btn-primary radius" onclick="updateStatus(2);" href="javascript:;">下架</a>
							<a class="btn btn-primary radius" onclick="updateStatus(0);" href="javascript:;">临时冻结</a>
						</div>
					</div>
				</c:if>
			

				<div class="form-group">
                   <label class="col-sm-2 control-label">商品名称</label>
                   <div class="col-sm-2">
                   	<input type="text" class="form-control" value="${goods.name}" placeholder="" id="" name="name" datatype="*" nullmsg="不能为空">
                   </div>
		                    
					<label class="col-sm-2 control-label">排序值</label>
					<div class="col-sm-2">
						<input type="text" class="form-control"
							value="${empty goods.sort ? 0 : goods.sort}" placeholder="" id=""
							name="sort">
					</div>				                     
		        </div>
				
			<div class="form-group">
				<input type="hidden" name="type" id="endType" value="${goods.type}">
				
				<label class="col-sm-2 control-label">所属品类</label>
				<div class="col-sm-2">
					 <select data-placeholder="选择大类" id="type1"  onchange="firstChange(this);" class="input-md form-control chosen-select" tabindex="4" >
							<option value="-1">--大类--</option>
							<c:forEach items="${types1}" var="type">
								<option value="${type.cCode}"
							<c:if test="${type.cCode==firstType.cCode}">selected</c:if>>${type.cName}</option>
							</c:forEach>
					</select>			
				</div>
				<div class="col-sm-2">
					<select data-placeholder="选择中类" id="type2"  onchange="secondChange(this);" onclick="secondClick(this)" class="input-md form-control chosen-select" tabindex="4">
							<option value="-1">--中类--</option>
							<c:forEach items="${types2}" var="type">
								<option value="${type.cCode}"
								<c:if test="${type.cCode==sencondType.cCode}">selected</c:if>>${type.cName}</option>
							</c:forEach>
					</select>			
				</div>
				<div class="col-sm-2">
					<select data-placeholder="选择小类" id="type3"  onclick="thirdClick(this)" class="input-md form-control chosen-select" tabindex="4">
							<option value="-1">--小类--</option>
							<c:forEach items="${types3}" var="type">
								<option value="${type.cCode}"
								<c:if test="${type.cCode==thiredType.cCode}">selected</c:if>>${type.cName}</option>
							</c:forEach>
					</select>				
				</div>
			</div>
					
			<div class="form-group">
				<label class="col-sm-2 control-label" >品牌</label>
				<div class="col-sm-2">
					<select data-placeholder="选择品牌" id="brand_id" name="brand_id" class="input-md form-control chosen-select" tabindex="4">
							<option value="-1">--请选择品牌--</option>
							<c:forEach items="${brandList}" var="brand">
								<option value="${brand.brand_id}"
									<c:if test="${brand.brand_id==goods.brand_id}">selected</c:if>>${brand.brand_name}</option>
							</c:forEach>
					</select>
				</div>
				<label class="col-sm-2 control-label">产地</label>
				<div class="col-sm-2">
					<input type="text" name="producing_area" id="" placeholder=""
						value="${goods.producing_area}" class="form-control">
				</div>				
			</div>
				
			<div class="form-group">				
				<label class="col-sm-2 control-label">价格</label>
				<div class="col-sm-2">
					<input type="text" class="form-control" value="${goods.price}" placeholder="" id="" name="price">
				</div>
				<label class="col-sm-2 control-label">已售数量</label>
				<div class="col-sm-2">
					<input type="text" class="form-control"
						value="${empty soldCount ? 0 : soldCount}" placeholder="" id=""
						name="count">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label">商品标签</label>
				<div class="col-sm-8 mt-5">
					<c:forEach items="${taglist}" var="tag">
						<input type="checkbox"
							<c:if test="${tag.is_select==1}">checked="checked"</c:if>
							value="${tag.gtag_id}" name="goodstags" height="150" >&nbsp;${tag.gtag_title}&nbsp;&nbsp;
					</c:forEach>
				</div>
			</div>

	</div>
	
			 <!-- 货品规格 -->
		 	<div class="ibox-content2">
		 			<div class="hr-line-solid2"></div>
		            <div class=ibox-title2> 
			           	<div class="col-sm-8 fl"><b class="b1">货品规格</b></div>
						<div class="col-sm-2 fr"><a
								class="btn btn-primary radius" onclick="addProduct();" href="javascript:;">添加</a></div>   
					</div>          
			</div>
		
			<div class="ibox-content">		
					
					<div class="form-group form-products">
						
						<div class="ml-30" id="productCtn">
							<input type="hidden" id="products_list" name="products_list"
								value="" />
		
							<c:forEach items="${products}" var="product" varStatus="varStatus">
								<div class="rule-con">
		
									${varStatus.count}：市场价&nbsp;&nbsp;<input
										type="text" name="${varStatus.count}_mkt"
										id="${varStatus.count}_mkt" placeholder="市场价"
										value="${product.mkt_price}"
										<c:if test="${varStatus.count==1}">datatype="/^[\d\.]+$/" nullmsg="不能为空"</c:if>
										class="form-control" style="width: 10%">&nbsp;元&nbsp;&nbsp;
									销售价&nbsp;&nbsp;<input type="text"
										name="${varStatus.count}_price" id="${varStatus.count}_price"
										<c:if test="${varStatus.count==1}">datatype="/^[\d\.]+$/" nullmsg="不能为空"</c:if>
										placeholder="销售价" value="${product.price}" class="form-control"
										style="width: 10%">&nbsp;元&nbsp;&nbsp; 规格描述&nbsp;&nbsp;<input type="text"
										name="${varStatus.count}_pdt_spec"
										id="${varStatus.count}_pdt_spec"
										<c:if test="${varStatus.count==1}">datatype="*" nullmsg="不能为空"</c:if>
										placeholder="示例: 500ML" value="${product.pdt_spec}"
										class="form-control" style="width: 10%">&nbsp;&nbsp; 库存&nbsp;&nbsp;<input type="text"
										name="${varStatus.count}_store" id="${varStatus.count}_store"
										<c:if test="${varStatus.count==1}">datatype="n" nullmsg="不能为空"</c:if>
										placeholder="库存" value="${product.store}" class="form-control"
										style="width: 5%">&nbsp;&nbsp; 单位&nbsp;&nbsp;<input
										type="text" name="${varStatus.count}_unit"
										id="${varStatus.count}_unit"
										<c:if test="${varStatus.count==1}">datatype="*" nullmsg="不能为空"</c:if>
										placeholder="单位" value="${product.unit}" class="form-control"
										style="width: 10%"> <input type="hidden"
										name="${varStatus.count}_productId"
										id="${varStatus.count}_productId" value="${product.product_id}">
									<span class="c-red">*</span>
									 <a style="text-decoration: none" class="btn btn-primary radius"
										onClick="product_disable(this,'${product.product_id}')"
										href="javascript:;" title="删除">删除</a>
								</div>
							</c:forEach>
							<c:if test="${empty products}">
								<div class="rule-con">
									1：市场价&nbsp;&nbsp;<input type="text"
										name="1_mkt" id="1_mkt" placeholder=" 市场价" value=""
										class="form-control" style="width: 10%" datatype="/^[\d\.]+$/"
										nullmsg="不能为空">&nbsp;元&nbsp;&nbsp; 销售价&nbsp;&nbsp;<input
										type="text" name="1_price" id="1_price" placeholder=" 销售价"
										value="${product.price}" class="form-control" style="width: 10%"
										datatype="/^[\d\.]+$/" nullmsg="不能为空">&nbsp;元&nbsp;&nbsp;
									规格描述&nbsp;&nbsp;<input type="text"
										name="1_pdt_spec" id="1_pdt_spec" placeholder=" 示例: 500ML"
										value="${product.pdt_spec}" class="form-control"
										style="width: 10%" datatype="*" nullmsg="不能为空">&nbsp;&nbsp;
									库存&nbsp;&nbsp;<input type="text"
										name="1_store" id="1_store" placeholder=" 库存"
										value="${product.store}" class="form-control" style="width: 5%"
										datatype="n" nullmsg="不能为空">&nbsp; 单位&nbsp;&nbsp;<input
										type="text" name="1_unit" id="1_unit" placeholder=" 单位"
										value="${product.unit}" class="form-control" style="width: 10%"
										datatype="*" nullmsg="不能为空"> <input type="hidden"
										name="1_productId" id="1_productId" value="0"> <a
										style="text-decoration: none" class="btn btn-primary radius"
										onClick="deleteProductForm(this);" href="javascript:;"
										title="删除">删除</a>
								</div>
							</c:if>
						</div>
					</div>
		  			
		  	</div>			
  			
  			<div class="ibox-content2">
	  			<div class="hr-line-solid2"></div>
		        <!-- 图片和描述 -->
	            <div class=ibox-title2> 
	                <h5>图片和描述</h5>
	            </div>             
			</div>
			
			<div class="ibox-content">
			
			<input type="hidden" class="form-control" id="covers" name="image" value="${goods.image}" />
			<div class="form-group webuploader2" id="uploader">
				<label class="col-sm-2 control-label">商品主图</label>
				<div class="col-sm-10 ">						
						<div  class="col-sm-2 m-l-n">
							<a id="iconbutton"><i class="iconfont icon-plus1"></i></a>						
							<br/>尺寸：380px *380px<br/>格式：JPG						
						</div>
						
						<div id="fileList_covers" class="col-sm-2 uploader-list">
						<c:if test="${!empty goods.image }">
							<img src="${goods.image}" height="100" border="0" />
						</c:if>
						</div>
						
				</div>					
			</div>

			<input type="hidden" id="image_list" name="image_list"
				value="${image_list}" /> 
			<input type="hidden" id="image_list_del"
				name="image_list_del" value="" />
			<div class="form-group">
				<label class="col-sm-2 control-label">商品介绍图</label>
				<div class="col-sm-10">
					<div class="col-sm-2 m-l-n">
						<a id="filePicker_resources"><i class="iconfont icon-plus1"></i></a>						
						<br/>尺寸：380px *380px<br/>格式：JPG						
					</div>
				 	<div id="fileList_resources" class="col-sm-8 uploader-list">
				 		<c:if test="${fn:length(images)>0}">
							<c:forEach items="${images}"
								var="image">
								<div id="image_${image.id}" class="file-item thumbnail upload-state-done">
									<a onclick="goods_p_delete(this, ${image.id});">删除</a> <img
										style="height: 100px;"
										src="${image.path}" />
									<div class="info">
										<input type="hidden" id="image_path_${image.id}" value="${image.path}" />
									</div>
								</div>
							</c:forEach>
						</c:if>
					</div> 
	
				</div>
			</div>											
		
			<div class="form-group">
					<label class="col-sm-2 control-label">详情图库</label>
				
					<div class="col-sm-10">						
						<div class="col-sm-2 m-l-n">
						<a id="xqTp_resources1"><i class="iconfont icon-plus1"></i></a>						
						<br/>尺寸：380px *380px<br/>格式：JPG						
					</div>
					<div id="fileList_xqt" class="col-sm-8 uploader-list">
							<!-- detailPics 商品详情 -->
							<c:forEach items="${detailPics}" var="image" varStatus="varStatus">
	
								<div class="file-item thumbnail upload-state-done">
								<a onclick="deleteDetailPic(this, ${image.id});">删除</a> 
								<img style="height: 100px;" src='${image.path}'></div>
	
							</c:forEach>			
					</div>
					<input type="hidden" name="detailPic" class="form-control" id="detail_pics" value="${image.path}" /> 
			</div>
			
			
			<div class="form-group">
				<label class="col-sm-2 control-label">商品属性</label>
				<div class="col-sm-8">
					<textarea name="property" data-provide="markdown" rows="5" class="textarea"
						placeholder="说点什么...最少输入10个字符" datatype="*0-200" dragonfly="true"
						nullmsg="备注不能为空！" onKeyUp="textarealength(this,200)">${goods.property}</textarea>
		
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label">详情描述</label>
				<div class="col-sm-8">
					<textarea name="description" data-provide="markdown" rows="5" class="textarea"
						placeholder="说点什么...最少输入10个字符" datatype="*0-200" dragonfly="true"
						nullmsg="备注不能为空！" onKeyUp="textarealength(this,200)">${goods.description}</textarea>
				</div>
			</div>
	
			<div class="form-group">
				<label class="col-sm-2 control-label">商品销售状态 </label>
				<div class="col-sm-8 mt-5">
					<c:if test="${empty goods.status}">
						<input type="radio" name="status" value="1" id="s1" checked="checked">
						<span class="btn btn-primary-line  btn-xs btn-line" for="s1">出售中</span>
						<input type="radio" name="status" value="2" id="s2">
						<span class="btn btn-default-line btn-xs btn-line" for="s2">下架区</span>
						<input type="radio" name="status" value="0" id="s3">
						<span class="btn btn-warning-line btn-xs btn-line" for="s3">仓库中</span>
					</c:if>
					<c:if test="${! empty goods.status}">
						<input type="radio" name="status" value="1" id="s1"
							<c:if test="${goods.status==1}">checked</c:if>>
						<span class="btn btn-primary-line  btn-xs btn-line" for="s1">出售中</span>
						<input type="radio" name="status" value="2" id="s2"
							<c:if test="${goods.status==2}">checked</c:if>>
						<span class="btn btn-default-line btn-xs btn-line" for="s2">下架区</span>
						<input type="radio" name="status" value="0" id="s3"
							<c:if test="${goods.status==0}">checked</c:if>>
						<span class="btn btn-warning-line btn-xs btn-line" for="s3">仓库中</span>
					</c:if>
				</div>
			</div>
			
										
			<div class="form-group mt-20">
				<label class="col-sm-2"></label>
				<div class="col-sm-8">
					<button onClick="goods_save();" id="goods-btn"
						class="btn btn-primary radius col-sm-2 " type="button">确认
					</button>&nbsp;&nbsp;&nbsp;&nbsp;
					<button onClick="layer_close();" class="btn btn-default radius pl-30 pr-30" type="button">取消</button>
				</div>
			</div>
				
				<button onClick="goods_save_submit();" id="save-btn" type="submit" style="display: none;">
					 保存并提交审核
				</button>				

	

		</div>

		</form>
	</div>
	<!-- /ibox -->
</div>
	
	<script src="${ctx}/static/js/jquery.min.js"></script>
	<script src="${ctx}/static/js/bootstrap.min.js"></script>

	
	<!-- 插件脚本 -->
	<script src="${ctx}/static/js/plugins/layer/layer.js"></script>	
	<script src="${ctx}/static/js/jquery.form.js"></script>
	<script src="${ctx}/static/js/plugins/webuploader/webuploader.min.js"></script>
	<script src="${ctx}/static/js/plugins/validate/jquery.validate.min.js"></script>
	<script src="${ctx}/static/js/Validform/5.3.2/Validform.min.js"></script>
	<script src="${ctx}/static/js/plugins/dataTables/jquery.dataTables.js"></script>
	<script src="${ctx}/static/js/plugins/dataTables/dataTables.bootstrap.js"></script>	
	<script type="text/javascript" src="${ctx}/static/js/plugins/markdown/markdown.js"></script>
    <script type="text/javascript" src="${ctx}/static/js/plugins/markdown/to-markdown.js"></script>
    <script type="text/javascript" src="${ctx}/static/js/plugins/markdown/bootstrap-markdown.js"></script>
    <script type="text/javascript" src="${ctx}/static/js/plugins/markdown/bootstrap-markdown.zh.js"></script>
    
	<script type="text/javascript">
	var isEdit = '${isEdit}';
	var allCities;
	var defaultCityId = '${goods.city_id}';
	var productSize = ${productSize};
	</script> 
	
	<script src="${ctx}/static/js/uthinkjs/goods.insert.js"></script>	
</body>
</html>